+2008-05-25 Matthias Clasen <mclasen@redhat.com>
+
+ Bug 501730 – use GSlice for small allocs
+
+ * gtk/gtkmenuitem.c:
+ * gtk/gtkmenu.c: Use the slice allocator for small allocations.
+ Patch by Christian Persch.
+
2008-05-25 Matthias Clasen <mclasen@redhat.com>
Bug 523930 – sort -> search in gtktreeview.c
gtk_widget_queue_resize (GTK_WIDGET (menu));
}
+static void
+attach_info_free (AttachInfo *info)
+{
+ g_slice_free (AttachInfo, info);
+}
+
static AttachInfo *
get_attach_info (GtkWidget *child)
{
if (!ai)
{
- ai = g_new0 (AttachInfo, 1);
- g_object_set_data_full (object, I_(ATTACH_INFO_KEY), ai, g_free);
+ ai = g_slice_new0 (AttachInfo);
+ g_object_set_data_full (object, I_(ATTACH_INFO_KEY), ai, attach_info_free);
}
return ai;
g_object_ref_sink (menu);
- data = g_new (GtkMenuAttachData, 1);
+ data = g_slice_new (GtkMenuAttachData);
data->attach_widget = attach_widget;
g_signal_connect (attach_widget, "screen_changed",
if (GTK_WIDGET_REALIZED (menu))
gtk_widget_unrealize (GTK_WIDGET (menu));
- g_free (data);
+ g_slice_free (GtkMenuAttachData, data);
/* Fallback title for menu comes from attach widget */
gtk_menu_update_title (menu);
gtk_menu_set_accel_path (GtkMenu *menu,
const gchar *accel_path)
{
+ gchar *old_accel_path;
+
g_return_if_fail (GTK_IS_MENU (menu));
if (accel_path)
g_return_if_fail (accel_path[0] == '<' && strchr (accel_path, '/')); /* simplistic check */
- g_free (menu->accel_path);
+ old_accel_path = menu->accel_path;
menu->accel_path = g_strdup (accel_path);
+ g_free (old_accel_path);
if (menu->accel_path)
_gtk_menu_refresh_accel_paths (menu, FALSE);
}
menu_item->toggle_size = allocation;
}
+static void
+free_timeval (GTimeVal *val)
+{
+ g_slice_free (GTimeVal, val);
+}
+
static void
gtk_menu_item_real_popup_submenu (GtkWidget *widget,
gboolean remember_exact_time)
if (remember_exact_time)
{
- GTimeVal *popup_time = g_new0 (GTimeVal, 1);
+ GTimeVal *popup_time = g_slice_new0 (GTimeVal);
g_get_current_time (popup_time);
g_object_set_data_full (G_OBJECT (menu_item->submenu),
"gtk-menu-exact-popup-time", popup_time,
- (GDestroyNotify) g_free);
+ (GDestroyNotify) free_timeval);
}
else
{
const gchar *accel_path)
{
GtkWidget *widget;
+ gchar *old_accel_path;
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
g_return_if_fail (accel_path == NULL ||
widget = GTK_WIDGET (menu_item);
/* store new path */
- g_free (menu_item->accel_path);
+ old_accel_path = menu_item->accel_path;
menu_item->accel_path = g_strdup (accel_path);
+ g_free (old_accel_path);
/* forget accelerators associated with old path */
gtk_widget_set_accel_path (widget, NULL, NULL);